package com.cetc.sdp.mzga.service.conn;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.cetc.sdp.mzga.service.conf.DBConf;

import java.sql.Connection;
import java.sql.SQLException;

import org.apache.log4j.Logger;

public class DruidPool {

	private final static  Logger LOG = Logger.getLogger(DruidPool.class);
	  
    private static DruidDataSource hbaseSource;

    private static DruidPool druidPool;


    static {
        druidPool = new DruidPool();
        try {
            hbaseSource = (DruidDataSource) DruidDataSourceFactory
                    .createDataSource(DBConf.getInstance().getProperties());
        } catch (Exception e) {
            LOG.error(e.getMessage());
            e.printStackTrace();
        }
    }

    private DruidPool() {}

    public static DruidPool getInstance() {
        return druidPool;
    }


    public Connection getHBaseConnection() throws SQLException {
    	Connection conn = null;
        try {
            conn =hbaseSource.getConnection();
          } catch (SQLException e) {
            LOG.error(e.getMessage());
          }
        return conn;
    }

}
